package container

import (
	"fmt"
	"strings"
)
import "sort"

func SumArr(arr []int) int {
	sum := 0
	for _, value := range arr {
		sum += value
	}

	return sum
}

func FindResultIndex(arr []int, result int) [][2]int {

	a := [][2]int{}
	for i := 0; i < len(arr); i++ {
		for j := i + 1; j < len(arr); j++ {
			if i+j == result {
				a = append(a, [2]int{i, j})
			}
		}
	}

	return a
}

func Print1() {
	var a = make([]string, 5, 10)
	for i := 0; i < 10; i++ {
		a = append(a, fmt.Sprintf("%v", i))
	}
	fmt.Println(a)
}

func SortSlice(s []int) {
	sort.Ints(s)
}

func WordCount(s string) map[string]int {
	var m = make(map[string]int)

	if len(s) == 0 {
		return m
	}

	var arr = strings.Split(s, " ")
	for _, key := range arr {
		if _, ok := m[key]; !ok {
			m[key] = 1
		} else {
			m[key] += 1
		}
	}

	return m
}

func Print2() {
	type Map map[string][]int

	var m = make(Map)

	s := []int{1, 2}
	s = append(s, 3)

	fmt.Printf("%+v\n", s)
	m["key"] = s

	s = append(s[:1], s[2:]...)
	fmt.Printf("%+v\n", s)
	fmt.Println(m)
}
